import {toRefs, ref,reactive, onUnmounted, onMounted  } from "vue"


export   function useMouse(){
  const state = reactive({x:0,y:0});
  const update = (e) => {
    state.x =e.pageX
    state.y =e.pageY
  }
  onMounted(()=>{
    window.addEventListener("mousemove",update)
  })
  onUnmounted(()=>{
    window.removeEventListener("mousemove",update)
  })
  return toRefs(state)
}

